﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using UtilityLibrary.WinControls;
using WeifenLuo.WinFormsUI.Docking;


namespace CodeMark
{
    public partial class frmLeft : DockContent
    {
        private OutlookBar OutlookBar1 = null;
        public frmLeft()    
        {
            InitializeComponent();
            //僅讓窗口在左邊顯示
            this.DockAreas = (WeifenLuo.WinFormsUI.Docking.DockAreas)(WeifenLuo.WinFormsUI.Docking.DockAreas.DockLeft);

            //以下代碼可通過數據表來自動產生
            OutlookBar1 = new OutlookBar();
            OutlookBarBand outlookShortcutsBand = new OutlookBarBand("销售管理");
            outlookShortcutsBand.SmallImageList = this.imgSmall;
            outlookShortcutsBand.LargeImageList = this.imgLarge;
            outlookShortcutsBand.Items.Add(new OutlookBarItem("訂單管理", 0));
            outlookShortcutsBand.Items.Add(new OutlookBarItem("客戶管理", 1));
            outlookShortcutsBand.TextColor = Color.Black;
            OutlookBar1.Bands.Add(outlookShortcutsBand);

            OutlookBarBand outlookShortcutsBand1 = new OutlookBarBand("采購管理");
            outlookShortcutsBand1.SmallImageList = this.imgSmall;
            outlookShortcutsBand1.LargeImageList = this.imgLarge;
            outlookShortcutsBand1.Items.Add(new OutlookBarItem("訂單管理", 0));
            outlookShortcutsBand1.Items.Add(new OutlookBarItem("客戶管理", 1));
            outlookShortcutsBand1.TextColor = Color.Red;
            OutlookBar1.Bands.Add(outlookShortcutsBand1);

            OutlookBar1.Dock = DockStyle.Fill;
            OutlookBar1.SetCurrentBand(0);

            OutlookBar1.ItemClicked += new OutlookBarItemClickedHandler(OnOutlookBarItemClicked);
            OutlookBar1.ItemDropped += new OutlookBarItemDroppedHandler(OnOutlookBarItemDropped);

            this.panel1.Controls.AddRange(new Control[] { OutlookBar1 });
        }

        private frmCodeList frmCodeList;
        private frmCodeAdd frmCodeAdd;

        private void OnOutlookBarItemClicked(OutlookBarBand band, OutlookBarItem item)
        {

            switch (item.Text)
            {
                case "訂單管理":
                    {
                        if (frmCodeList == null || frmCodeList.IsDisposed)
                        {
                            frmCodeList = new frmCodeList();
                            frmCodeList.Show(frmMain.frmTemp.dockPanel1);
                        }
                        else
                        {
                            frmCodeList.Activate();
                        }

                        break;
                    }
                case "客戶管理":
                    {
                        if (frmCodeAdd == null || frmCodeAdd.IsDisposed)
                        {
                            frmCodeAdd = new frmCodeAdd();
                            frmCodeAdd.Show(frmMain.frmTemp.dockPanel1);
                        }
                        else
                        {
                            frmCodeAdd.Activate();
                        }
                        break;
                    }
                default:
                    break;
            }
        }

        private void OnOutlookBarItemDropped(OutlookBarBand band, OutlookBarItem item)
        {
            string message = "Item : " + item.Text + " was dropped";
            MessageBox.Show(message);
        }
    }
}
